/* 
 * Javascript per la gestione del login
 */

function login() {
    var username = $('#username').val();
    var password = $('#password').val();
    var link = "index.php";

    var data = "username="+username+"&password="+password;

    $.ajax({
	  type: "POST",
	  url: "fe/login/LoginAction.php",
	  data: data,
	  success: function(data){
           obj = JSON.parse(data);
           if(obj != null &&
                   obj.esito == 1) {
                setCookie();
                window.location=link;
                    
           } else {
               $('#erroreLogin').show();

                }

            },
          error:function(){
                $('#erroreLogin').show();
            }

	});

}

